#include <iostream>
#include<string>
#include <aes.h>
#pragma comment( lib, "cryptlib.lib" )
using namespace std;
using namespace CryptoPP;
int main()
{
	string message;
	cout << "Enter the message to encrypt(less than 16 characters): ";
	getline(cin, message);
	AESEncryption AES_encrypt;
	unsigned char key[AES::DEFAULT_KEYLENGTH];
	unsigned char toEncrypt[AES::BLOCKSIZE]="";
	for (int i = 0; i < message.length(); i++)
	{
		toEncrypt[i] = message[i];
	}
	unsigned char encrypted[AES::BLOCKSIZE];
	unsigned char middle_encrypt[AES::BLOCKSIZE];
	memset(middle_encrypt, 0, AES::BLOCKSIZE);
	AES_encrypt.SetKey(key, AES::DEFAULT_KEYLENGTH);
	cout << "the key of AES is ";
	for (int i = 0; i<16; i++)
	{
		cout << hex << (int)key[i] << " ";
	}
	cout<< "\nThe encrypted message is ";
	AES_encrypt.ProcessAndXorBlock(toEncrypt, middle_encrypt, encrypted);
	for (int i = 0; i<16; i++)
	{
		cout << hex << (int)encrypted[i] << " ";
	}
	cout << endl;
	AESDecryption AES_decrypt;
	unsigned char orignalMessage[AES::BLOCKSIZE];
	AES_decrypt.SetKey(key, AES::DEFAULT_KEYLENGTH);
	AES_decrypt.ProcessAndXorBlock(encrypted, middle_encrypt, orignalMessage);
	cout << "the orignal message is ";
	for (int i = 0; i<16; i++)
	{
		cout << orignalMessage[i];
	}
	cout << endl;
	system("pause");
	return 0;
}